//
//  PortManager.c
//  moonlight-common
//
//  Created by 清风徐来 on 2023/6/16.
//  Copyright © 2023 Moonlight Stream. All rights reserved.
//

#include "PortManager.h"

unsigned short getCustomPortFromPortFlagIndex(unsigned short port) {
    printf("传入的port = %d\n", port);
    
    // 这里应该从本地获取，临时测试 改为一一对应
    switch (port) {
            // TCP ports
        case 47984: return customPort47984;
            break;
        case 47989: return customPort47989;
            break;
        case 48010: return customPort48010;
            break;
            
            // UDP ports
        case 47998: return customPort47998;
            break;
        case 47999: return customPort47999;
            break;
        case 48000: return customPort48000;
            break;
        case 48002: return customPort48002;
            break;
        case 47009: return 47009;  // Moonlight Internet Hosting Tool为WoL开放的端口(非特权端口) 唤醒设备需要用，这个不能被替换
            break;
        default: return 0;
            break;
    }
 
}

//MARK - 打印端口信息
void printPort(void) {
    printf("转换后的47984端口为：%d\n", customPort47984);
    printf("转换后的47989端口为：%d\n", customPort47989);
    printf("转换后的48010端口为：%d\n", customPort48010);
    printf("转换后的47998端口为：%d\n", customPort47998);
    printf("转换后的47999端口为：%d\n", customPort47999);
    printf("转换后的48000端口为：%d\n", customPort48000);
    printf("转换后的48002端口为：%d\n", customPort48002);
}

/// 获取默认端口号（也应该是从接口获取）
unsigned short getDefaultPort(void) {
    return customPort47989;
}
